#!bin/bash


if [ -n "$1" ] ; then
  data_date=$1
else
  data_date=`date -d '-1 days' +%F`
fi

DWS_USER_ACTIVITY_DAY_SQL="
INSERT OVERWRITE TABLE wyy_music_warehouse.dws_user_activity_day PARTITION (dt = '2025-07-25')
SELECT
    client_device_id,action_type
FROM wyy_music_warehouse.dwd_event_log_detail
WHERE dt = '2025-07-25'
GROUP BY client_device_id,action_type
;
"

DWS_USER_NEW_SQL="
INSERT OVERWRITE TABLE wyy_music_warehouse.dws_user_new PARTITION (dt = '2025-07-23')
SELECT
    client_device_id as device_id
FROM wyy_music_warehouse.dwd_event_log_detail
WHERE client_register_date = '2025-07-23'
GROUP BY client_device_id,client_register_date
;
"

/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -p 123456 -e "${DWS_USER_ACTIVITY_DAY_SQL}${DWS_USER_NEW_SQL}"


